#include "TableSymb.hpp"

using namespace std;

TableSymb::TableSymb(string n, TableSymb* t)
{
    this->nom = n;
    this->tSymbMere = t;
}

void TableSymb::Ajout(Symbole *Sym, int i)
{
  this->TS[i] = Sym;
}

void TableSymb::Afficher()
{

    string tSymM;
    if (this->tSymbMere == NULL){
        tSymM = "None";
    }else{
        tSymM = this->tSymbMere->getName();
    }

    cout << "Table Symboles (" << this->getName()
		<< ","<< tSymM << ")" << endl;

    for (map<int, Symbole*>::iterator it = TS.begin(); it != TS.end(); ++it){
        cout << it->first << "\t"
			<< TS.at(it->first)->toString()<<endl;
    }

    //cout << "---SymbolTable(" << this->getName()
	//	<< ": "<< tSymM << ")" << endl;
	cout << endl;

}

TableSymb::~TableSymb(void)
{

}

string TableSymb::getName(void){
    return nom;
}

TableSymb *TableSymb::getParent()
{
	return this->tSymbMere;
}

Symbole *TableSymb::getSymbole(int id)
{
 if ( this->TS.find(id) == this->TS.end() ) {
    return NULL;
  }else {
    return this->TS[id];
  }
}

int TableSymb::getNbrSym()
{
    return this->TS.size();
}
